<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<script src="prototype-1.6.0.3.js"></script>

<script>
function searchall()
{
	var url = 'http://localhost:9090/helloStruts2/prototypetestall.action';
	var pars = '';
	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get', 
			parameters: pars, 
			onComplete: showResponse
		});
	
}

function searchbydeptno()
{
	var url = 'http://localhost:9090/helloStruts2/prototypetestbydeptno.action';
	
	var deptno = $F('inputparam');
	
	
	var pars = 'deptno=' + deptno;
	

	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get', 
			parameters: pars, 
			onComplete: showResponse
		});
	
}

function showResponse(originalRequest)
{
	
	
	$('resultDiv').innerHTML = originalRequest.responseText;
	
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>

<body>
<table>
<tr>
	<td>----- struts2의 ajax -----</td>
	<td>----- prototype의 ajx -----</td>
	<td></td>
</tr>
<tr>
	<td><s:head theme="ajax"/>
	<s:a href="empall.action" theme="ajax" targets="resultDiv">	
		<input value="전체목록" type="button">		
	</s:a>
	<s:form id="url" action="empallbydeptno" theme="ajax" target="resultDiv">
	<s:textfield name="deptno" size="4"/><s:submit targets="resultDiv" theme="ajax" value="검색"/>
	</s:form>	
	</td>
	<td>
	<!-- prototype의 ajax구현 -->
	<input type="button" value="전체목록" onclick="searchall()"/><br>
	<input type="text" size="4" id="inputparam"/><input type="button" value="검색" onclick="searchbydeptno()"/>	
	</td>
	<td></td>
</tr>
<tr>
	<td>----- struts2의 ajax -----</td>
	<td>----- prototype의 ajax -----</td>
	<td></td>
</tr>

<!-- 
<s:a href="%{url}" theme="ajax" targets="resultDiv">		
	<input value="검색" type="button">
</s:a>-->
</table>
<s:div id="resultDiv"></s:div>

</body>
</html>


